<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>

<body>
    <input type="text" name="" id="while" placeholder="while循环"><br>


    <script>
        var a = 1;
        var sum = 0;
        while (a <= 100) {
            sum += a; //sun= a+sum
            a++;
        }
        document.getElementById("while").value = sum;
        var a = 1;
        while (a <= 100) {
            if (a % 7 === 0) {
                document.write(a + "<br/>")
            }
            a++;
        }
        var b = 1;
        while (b <= 100) {
            if (b % 2 != 0) {
                document.write(b + "<br/>");
            }
            b++;
        }
        var c = 1;
        var sum = 0; //用于记录累加的和
        while (c <= 100) {
            if (c % 2 === 0) {
                sum += c;
            }
            c++;
        }
        alert(sum);
        var d = 0;
        while (d < 40) {
            if (d % 10 === 0) {
                document.write("<br>")
            }
            document.write("*");
            d++;
        }
    </script>
</body>

</html>